package com.zmn.oms.services.impl.remark;

import com.zmn.oms.model.entity.remark.OrderRemarkDetail;
import com.zmn.oms.model.entity.remark.OrderRemarkDetailQuery;
import com.zmn.oms.persistence.interfaces.remark.OrderRemarkDetailDao;
import com.zmn.oms.services.interfaces.remark.OrderRemarkDetailService;
import io.shardingsphere.api.HintManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类描述：订单备注详情
 *
 * @author lujia
 * @date 2018/11/28 17:10
 */
@Service
public class OrderRemarkDetailServiceImpl implements OrderRemarkDetailService {

    @Autowired
    private OrderRemarkDetailDao orderRemarkDetailDao;

    @Override
    public List<OrderRemarkDetail> listOrderRemarkDetailByOrderIdList(List<Long> orderIdList) {
        try (HintManager hintManager = HintManager.getInstance()) {
            hintManager.setMasterRouteOnly();
            return orderRemarkDetailDao.listOrderRemarkDetailByOrderIdList(orderIdList);
        }
    }

    @Override
    public List<OrderRemarkDetail> listOrderRemarkDetailByRemarkId(Long orderId, Long workId, Long remarkId) {
        OrderRemarkDetailQuery query = new OrderRemarkDetailQuery();
        query.setOrderId(orderId);
        query.setWorkId(workId);
        query.setRemarkId(remarkId);
        return orderRemarkDetailDao.listOrderRemarkDetailByQuery(query);
    }

    @Override
    public void deleteOrderRemarkDetailByParams(OrderRemarkDetail orderRemarkDetail) {
        orderRemarkDetailDao.deleteOrderRemarkDetailByParams(orderRemarkDetail);
    }

    @Override
    public void insertOrderRemarkList(List<OrderRemarkDetail> detailList) {
        orderRemarkDetailDao.insertOrderRemarkList(detailList);
    }
}
